package com.zq.controller;

import com.zq.entity.User;
import com.zq.repository.UserRepository;
import com.zq.service.UserService;
import com.zq.utils.FenyeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Optional;

/**
 * @Author:任人渐疏
 * @Date:Created in 3:30 下午 2020/6/26
 * Update:true
 */
@RestController
@RequestMapping("user")
public class UserController {
@Autowired
    private UserRepository userRepository;
@Autowired
    private UserService userService;
    @GetMapping
    public  Object getListAllUser(User user,Integer page){
        FenyeUtil<User> all = userService.findAll(user, page-1);
        return all;
    }
    @PostMapping
    public  Object xiugaiUser(User user){
        return  userService.addUser(user);
    }
    @PutMapping
    public  Object tianjiaUser(User user){
        return  userService.updateUser(user);
    }
    @DeleteMapping
    public  Object deleteUser(String uids){
        return userService.deleteUser(uids);

    }
    @GetMapping("jianchaNiCheng")
    public  Object jianchaNicheng(String nicheng){
        return userRepository.findBynicheng(nicheng);
    }
    @GetMapping("jianchaYongHuMing")
    public  Object jianchayonghuming(String yonghuming){
        return userRepository.findByUname(yonghuming);
    }
    @GetMapping("getAllUser")
    public  Object getAllTag(){
        return userRepository.getAllUser();
    }
}
